package com.fastTools.check;

import java.util.Collection;
import java.util.function.Function;

public class Argument {

    public Argument() {
    }

    public static boolean isPositive(Integer argument) {
        return argument != null && argument > 0;
    }

    public <D> D ifPositive(Integer arg, Function<Integer, D> function) {
        return arg != null && arg > 0 ? function.apply(arg) : null;
    }

    public static boolean isPositive(Long argument) {
        return argument != null && argument > 0L;
    }

    public <D> D ifPositive(Long arg, Function<Long, D> function) {
        return arg != null && arg > 0L ? function.apply(arg) : null;
    }

    public static boolean isNotPositive(Integer argument) {
        return argument == null || argument <= 0;
    }

    public static boolean isNotPositive(Long argument) {
        return argument == null || argument <= 0L;
    }

    public static boolean isPositive(Number argument) {
        if (argument == null) {
            return false;
        } else {
            return argument.floatValue() > 0.0F || argument.intValue() > 0;
        }
    }

    public static boolean isNull(Object argument) {
        return argument == null;
    }

    public static boolean isEmpty(Collection argument) {
        return isNull(argument) || argument.isEmpty();
    }

    public static boolean isNotNull(Object argument) {
        return argument != null;
    }

    public static boolean isNotEmpty(Collection argument) {
        return !isEmpty(argument);
    }

    public static boolean isNotBlank(Object argument) {
        return argument != null && argument != "";
    }

    public static boolean isNotEmptyArray(Object[] array) {
        return !isEmptyArray(array);
    }

    public static boolean isEmptyArray(Object[] array) {
        return isNull(array) || array.length == 0;
    }

    public static boolean integerEqual(Integer num1, Integer num2) {
        return num1 == null ? num2 == null : num1.equals(num2);
    }

    public static boolean longEqual(Long num1, Long num2) {
        return num1 == null ? num2 == null : num1.equals(num2);
    }
}
